package com.alpha.core.utils;

import cn.hutool.core.io.IORuntimeException;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.net.URL;

/**
 * 文件工具类
 *
 * @author chenruwan
 * @since 2022-01-01
 */
@Slf4j
@SuppressWarnings("unused")
public class FileUtil {
    private FileUtil() {
    }

    public static URL getResource(String name) {
        return FileUtil.class.getResource(name);
    }

    public static File file(String path) {
        return cn.hutool.core.io.FileUtil.file(path);
    }

    public static File newFile(String path) {
        return cn.hutool.core.io.FileUtil.newFile(path);
    }

    @CanIgnoreReturnValue
    public static boolean clean(String dirPath) throws IORuntimeException {
        return cn.hutool.core.io.FileUtil.clean(dirPath);
    }

    @CanIgnoreReturnValue
    public static File mkdir(String dirPath) {
        return cn.hutool.core.io.FileUtil.mkdir(dirPath);
    }
}
